package com.twp.auth.config;

import com.twp.auth.config.auth.AuthConfig;
import com.twp.auth.security.MyUserDetailsService;
import com.twp.common.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;

public class MyWebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    AuthConfig authConfig;

    @Autowired
    MyUserDetailsService myUserDetailsService;

//    @Override
//    protected void configure(AuthenticationManagerBuilder manage) throws Exception {
//        manage.userDetailsService(myUserDetailsService).passwordEncoder(new PasswordEncoder(){
//
//            @Override
//            public String encode(CharSequence rawPassword) {
//                return MD5Util.encode(authConfig.getSalt(),(String)rawPassword);
//            }
//
//            @Override
//            public boolean matches(CharSequence rawPassword, String encodedPassword) {
//                return encodedPassword.equals(MD5Util.encode(authConfig.getSalt(),(String)rawPassword));
//            }}); //user Details Service验证
//    }
}
